package com.example.demo.component.k8s;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName k8s_client_factory
 * @Description
 * @date 2022/11/8 14:36
 * @Author yanceysong
 * @Version 1.0
 */
public class k8s_client_factory {

    private static final ConcurrentHashMap<String, k8s_client> k8s_client_pool = new ConcurrentHashMap<>();

    /**
     * 获取k8s_client连接
     *
     * @param host_ip ip地址
     * @return 连接
     */
    public static k8s_client get_k8s_client(String host_ip) {
        if (!k8s_client_pool.containsKey(host_ip)) {
            k8s_client_pool.put(host_ip, new k8s_client(k8s_enum.get_config_path(host_ip)));
        }
        return k8s_client_pool.get(host_ip);
    }
}
